/**
*      author: Y_Yao
*      created: 2024-12-03 21:30:53
**/

#include<bits/stdc++.h>

using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 1e3 + 7;
const int M = 1e4 + 7;
int a[N][N];
int n,m;
int Time[M],x[M],y[M];
int dp[M];

void solve()
{
    cin >> n >> m;
    for(int i = 1;i <= m;i++)
    {
        cin >> Time[i] >> x[i] >> y[i];
    }
    int ans = 0;
    dp[1] = 1;
    for(int i = 1;i <= m;i++)
    {
        dp[i] = 1;
        for(int j = 1;j < i;j++)
        {
            if(abs(Time[i] - Time[j]) >= abs(x[i] - x[j]) + abs(y[i]- y[j]))
            {
                dp[i] = max(dp[i],dp[j] + 1);
            }
        }
        ans = max(ans,dp[i]);
    }

    cout << ans << endl;

}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}